package com.tensquare.article.dao;

import com.tensquare.article.pojo.Article;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @author Macross
 * @Type ArticleDao.java
 * @Desc 文章信息dao接口
 * @date 2019/12/17 19:39
 */
public interface ArticleDao extends JpaRepository<Article,String>,JpaSpecificationExecutor<Article>{

    /**
     * 指定文章审核
     * @param articleId 文章id
     */
    @Modifying
    @Query(
            nativeQuery = true,
            value = "update tb_article set state ='1' where id = ?1"
    )
    void updateState(String articleId);

    /**
     * 文章点赞数+1
     * @param articleId 文章id
     */
    @Modifying
    @Query(
            nativeQuery = true,
            value = "update tb_article set thumbup = thumbup + 1 where id = ?1"
    )
    void updateThumbup(String articleId);
}

